/**
 * Copyright 2018 人人开源 http://www.renren.io
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.hs.srm.admin.common.config;

import java.util.Properties;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;

/**
 * 生成验证码配置
 *
 * @author Mark sunlightcs@gmail.com
 * @since 2.1.0 2017-04-20
 */
@Configuration
public class KaptchaConfig {

    @Value("${hssrm.hasCaptcha}")
    private String hasCaptcha;

    @Bean
    public DefaultKaptcha producer() {
        Properties properties = new Properties();
        properties.put("kaptcha.border", "no");
        properties.put("kaptcha.textproducer.char.space", "4");
        properties.put("kaptcha.border.color", "255,43,27");
        properties.put("kaptcha.textproducer.font.names", "宋体");
        properties.put("kaptcha.textproducer.font.color", "white");
        properties.put("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.ShadowGimpy");
        properties.put("kaptcha.background.impl", "com.google.code.kaptcha.impl.DefaultBackground");
        properties.put("kaptcha.background.clear.from", "71,134,255");
        properties.put("kaptcha.background.clear.to", "white");
        properties.put("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise");
        properties.put("kaptcha.noise.color", "black");
        properties.put("kaptcha.word.impl", "com.google.code.kaptcha.text.impl.DefaultWordRenderer");
       /* properties.put("", "");
        properties.put("", "");
        properties.put("", "");
        properties.put("", "");
        properties.put("", "");*/
        Config config = new Config(properties);
        DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
        defaultKaptcha.setConfig(config);
        return defaultKaptcha;
    }

    public String getHasCaptcha() {
        return this.hasCaptcha;
    }

    public void setHasCaptcha(String hasCaptcha) {
        this.hasCaptcha = hasCaptcha;
    }
}
